WEBVTT

00:01.120 --> 00:03.760
Hello and welcome back to the costs Sunday.

00:03.790 --> 00:09.430
Last two sessions we learned already about the data types integers and floats.

00:09.430 --> 00:17.160
And in this session we want to repeat and deepen our understanding of those two data types.

00:17.170 --> 00:22.120
So first of all we assign variables to let's say five.

00:22.150 --> 00:29.290
So we assign the arrival eight to five and we assign B to the Internet two.

00:29.980 --> 00:37.960
And we check the data types of A and B so I would expect that A and B are integers.

00:38.320 --> 00:39.070
That's true.

00:39.070 --> 00:44.620
Here you can see Integer Integer and what we already learned.

00:44.620 --> 00:46.310
I mean integer floats.

00:46.330 --> 00:54.850
That's both them are ordinary numbers where we can apply a mathematical operations like addition so

00:54.850 --> 00:59.230
we can add a plus b we can add B plus a.

00:59.320 --> 01:05.410
So no surprise we get seven and both uh and both operations that we can subtract.

01:05.410 --> 01:08.620
So A minus B plus three.

01:08.620 --> 01:15.280
We can also create negative numbers B minus a gives us minus three.

01:15.280 --> 01:20.430
And also we can multiply two integers and get 10.

01:20.740 --> 01:26.360
And uh what we also already learned is that by dividing into Test B.

01:26.380 --> 01:26.550
Yeah.

01:26.560 --> 01:28.230
We get on and float object.

01:28.240 --> 01:39.310
So if we uh divide a divided by B So five divided by two we get 2.5 and we assign 2.5 to the right of

01:39.310 --> 01:39.780
C..

01:40.690 --> 01:42.760
So C is 2.5.

01:43.000 --> 01:51.360
And uh the data type of C is a float object and that's actually the difference between antigen and then

01:51.360 --> 01:55.710
float integers a number that can be written without fractional component.

01:55.740 --> 02:01.290
So 5 or 2 both don't have any any decimal.

02:01.440 --> 02:09.510
And in contrast a float object has a decimal so if you can see here C has a that one decimal point five

02:11.210 --> 02:16.310
at this point I want to highlight the different data types have different functionality and all the

02:16.400 --> 02:21.570
data types have so-called built in methods or attributes.

02:21.620 --> 02:27.560
So actually at this point I don't want to go into detail of object oriented programming but I want to

02:27.560 --> 02:32.420
show you the practical use of the so-called methods and attributes.

02:32.420 --> 02:41.480
So let's have a look at um the float the float object see and we can call the method as integer array

02:41.480 --> 02:53.640
so by pressing C dot and then s integer ratio and if we execute the cell here it can see that C as an

02:53.640 --> 02:56.820
integer Horatio is five divided pi 2.

02:57.150 --> 03:03.420
So this is called a method because Python internally calculates something based on our object.

03:03.450 --> 03:04.200
Um yeah.

03:04.200 --> 03:05.490
2.5.

03:05.490 --> 03:11.100
So it returns the integer ratio of 5 will divided by 2.

03:11.550 --> 03:20.490
And we can also browse or search for built in methods or attributes by just uh uh let's take uh the

03:20.670 --> 03:28.110
float C dot and then press tab and then we can see what Python offers us.

03:28.140 --> 03:37.000
So we have a method as integral ratio and uh with quite a few methods and then attributes here.

03:37.020 --> 03:44.500
So for instance we can call the method as integer and executed.

03:44.540 --> 03:52.290
Okay so now python is checking if C as a float as an integer and obviously it's not an integer so it

03:52.290 --> 04:04.380
returns a false so now if you go to our variable B is the B stands for 4 2 so it's B is an integer and

04:04.390 --> 04:07.740
then we can call the attribute denominator.

04:10.270 --> 04:14.220
And numerator Casale actually that squared.

04:14.280 --> 04:14.930
Yeah.

04:15.150 --> 04:18.890
I mean that's not too much too much more information here.

04:18.900 --> 04:21.990
So two is made of the numerator.

04:21.990 --> 04:23.490
Two divided by one.

04:23.490 --> 04:26.670
So that's not not too much helpful actually.

04:27.780 --> 04:36.060
And we can also check here what other methods or attributes we have by pressing the tap key bit length

04:36.120 --> 04:37.340
conjugate.

04:37.740 --> 04:39.870
It's not too interesting for us now.

04:39.990 --> 04:48.300
So I think we should go on and um yeah let's let's calculate 11 divided by three and assign it to the

04:48.300 --> 04:49.890
variety of D.

04:50.160 --> 04:52.700
Gives us three points six six six.

04:53.550 --> 05:01.330
And the if you call now the method as integer ratio you have to get quite quiet.

05:01.360 --> 05:02.440
Um yeah.

05:02.540 --> 05:04.260
It doesn't give us what we expected.

05:04.290 --> 05:09.750
Um eleven and three because um the float a C uh by default around it.

05:09.780 --> 05:10.630
After uh.

05:10.770 --> 05:18.290
I don't know the tenth uh digit so now I mean doesn't have too much here.

05:18.300 --> 05:21.570
The two numbers but nice to know actually.

05:21.760 --> 05:22.940
And um yeah.

05:22.950 --> 05:31.030
What we can also do we can call a function on an object like this or a function like round so we can

05:31.030 --> 05:36.610
round our float object and let's press shift tab to.

05:36.680 --> 05:44.920
Okay we can round a number so it s d s stands for a float and we can also determine the number of digits.

05:44.920 --> 05:54.640
So if we take here 1 so we can round our float object here to 1 digit and we get three point seven.

05:54.670 --> 06:03.940
So if we change it here to 2 we get three point six seven obviously with uh into the integers rounding

06:03.940 --> 06:08.240
doesn't make really sense because we are an integer doesn't have any digits.

06:08.410 --> 06:17.740
And what we can also do we can transform our flowed into an integer by calling the function int so INT.

06:17.800 --> 06:24.300
And then in brackets to give them the corresponding integer to the float D.

06:24.580 --> 06:31.420
And what Python actually does it just cuts here um all digits so that's not rounding if it's would round

06:31.450 --> 06:38.380
so we would get four but it's just cutting here after the three and we get um the integer three

06:41.260 --> 06:51.110
and we can also transform an integer A stands for five into a float and gives us five point zero and

06:51.110 --> 06:54.170
there are two ways to transform an integer into a float.

06:54.290 --> 07:03.830
So either we call the function float or um so let's check first of all the type of uh five should be

07:03.830 --> 07:04.520
an integer.

07:04.910 --> 07:16.280
And if you just press 5 dot 0 Python recognizes 5.0 as a float and even we don't have to press 0 so

07:16.310 --> 07:20.070
only five point nothing gives us a float.

07:20.070 --> 07:27.220
So Python treats as of a float and also here there are two ways to transform an integer into a string.

07:27.770 --> 07:38.110
So either by uh setting or putting five into quotation marks or by calling the s t r function.

07:38.410 --> 07:44.930
So by calling a c r our five will be transformed into a string.

07:44.990 --> 07:47.040
All right so that s the same as here.

07:47.970 --> 07:48.200
Yeah.

07:48.200 --> 07:50.360
That's it for now at this point.

07:50.360 --> 07:54.880
So that's not much more to say about integers and floats and.

07:54.970 --> 07:55.490
Yeah.

07:55.510 --> 07:58.550
In the next session we will have a deeper look into uh.

07:58.580 --> 07:59.430
String object.

07:59.430 --> 08:03.980
So hope you enjoyed it and uh hope to see you in the next session.

08:04.010 --> 08:04.280
By.
